package com.cy.pj.sys.web.interceptor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalTime;

public class TimeAccessInterceptor2 implements HandlerInterceptor {
    private static final Logger log = LoggerFactory.getLogger(HandlerInterceptor.class);

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        LocalTime time = LocalTime.now();
        int i = time.getHour();
        if (i>6&&i<24){
            log.info("你被放行了,{}",i);
            return true;
        }
        System.out.println("你被拦截了!!!!!!!!!!!!!");
        return false;
    }
}
